package 剑指offer;

import java.util.Arrays;

public class _16 {
    public double myPow(double x, int n) {
        int res = 1;
        if(n > 0){
            while (n > 0){
                res *= x;
                n--;
            }
        }else if(n < 0){
            n = Math.abs(n);
            while (n > 0){
                res *= x;
                n--;
            }
            res = 1 / res;
        }
        return res;
    }
}
